class Solution {
public:
    string addStrings(string num1, string num2) {
        int end1=num1.size()-1;
        int end2=num2.size()-1;
        int carry=0;
        int ret=0;
        string strret;
        while(end1>=0||end2>=0)
        {
            int ret1=(end1>=0)?num1[end1]-'0':0;
            int ret2=(end2>=0)?num2[end2]-'0':0;
            ret=ret1+ret2+carry;
            carry=ret/10;
            ret%=10;
            --end1;
            --end2;
            strret+=('0'+ret);
        }
        reverse(strret.begin(),strret.end());
        if(carry==1)
        {
            strret.insert(strret.begin(),'1');
        }
        
        return strret;
    }
};
